Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Add go to definition for packages - #27

Merged
mlorbetske merged 1 commit into
masterfrom
dev/mlorbe/AddGoToDefinitionForPackages
Sep 6, 2017
Merged

mlorbetske merged 1 commit into
masterfrom
dev/mlorbe/AddGoToDefinitionForPackages

Conversation

@mlorbetske

Copy link
Copy Markdown
Contributor

Fixes #26

@mlorbetske
mlorbetske requested a review from adrianvmsft August 24, 2017 05:33
@dnfclas

dnfclas commented Aug 24, 2017

Copy link
Copy Markdown

@mlorbetske,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

@mlorbetske
mlorbetske force-pushed the dev/mlorbe/AddGoToDefinitionForPackages branch from 55163a7 to f74c2ca Compare August 24, 2017 05:33
@adrianvmsft

adrianvmsft commented Aug 24, 2017 •

Copy link
Copy Markdown
Contributor

Nice! 👍


private static bool PackageExistsOnNuGet(string packageName, string version, out string url)
{
string packageAndVersionUrl = $"https://www.nuget.org/packages/{packageName}/{version}/";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if the logic of finding the Nuget package would reside inside the .Nuget project.

On a side note, the Definition class is intended to be an abstraction level for the set of matches. However, the implementation currently is very limited (we would need to implement what we were calling Resolvers; that would allow us to write this code in a more generic way).

For now, I think that is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #29 to track moving the logic

@mlorbetske
mlorbetske merged commit 7b31391 into master Sep 6, 2017
@mlorbetske
mlorbetske deleted the dev/mlorbe/AddGoToDefinitionForPackages branch September 6, 2017 19:48
}
else
{
response = client.GetAsync(packageAndVersionUrl).Result;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you fetching the same URL again? Isn't this supposed to be packageUrl?

{
HttpResponseMessage response = client.GetAsync(packageAndVersionUrl).Result;

if (response.StatusCode == System.Net.HttpStatusCode.OK)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of a NuGet gallery bug (NuGet/NuGetGallery#4624), this will always be true, as long as the package ID is correct.

{
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = client.GetAsync(packageAndVersionUrl).Result;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to issue a HEAD request here? You're not interested in the body after all...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants